<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <common-head></common-head>
  </div>
  <script src="./vue.js"></script>
  <script>
    const CommonHead = {
      template: `
       <div>
         <h2>这是一个公共的头部</h2>  
         <logo :a="msg"></logo>
       </div>
     `,
      data() {
        return {
         msg:'父组件的数据'
        }
      },
      components: {
        Logo: {
          template: `
            <div>
              <h3>这是一个局部组件</h3>  
              <button @click="changeProp">直接修改prop</button>
              {{a}}
            </div>
        `,
          // props验证
          props: {
            // 只验证数据类型
            a: String,
          },
          data() {
            return {
              bb: 'dwfdw'
            }
          },
          methods: {
            changeProp(){
              this.a = '值改变了';
            }
          },
          mounted() {
            console.log(this);
          }
        }
      }
    }
    Vue.component('CommonHead', CommonHead);
    // 相当于定义一个 组件构造函数 VueComponent(继承Vue)
    const vm = new Vue({
      el: '#app'
    })
  </script>
</body>

</html>